#ifndef INTERFACE_CYCLE_BUTTON_HPP
#define INTERFACE_CYCLE_BUTTON_HPP

#include "Widget.hpp"
#include "Button.hpp"
#include "Textbox.hpp"

namespace mi
{
    class CycleButton : public Widget, public Callable
    {
    public:
        CycleButton();

        // cycle button specific functions

        CycleButton& AddOption (std::string option);

        CycleButton& RemoveOption(std::string option);

        std::string CurrentOption ();

        // input override functions

        Widget* MouseClick(sf::Mouse::Button button, sf::MouseState state, int x, int y);
    
        Widget* MouseMoved(int x, int y, int dx, int dy);
        
        Widget* MouseDragged(int x, int y, int dx, int dy);

        void SetCallbackFunction(Callable* object, CallableFunction function);

        // Overwrite the pure virtuals from Widget

        void Draw2D ();

        bool Update (double dTime);

        void EventCallback (mi::Event e);
        
        bool Contains(Widget* other);

        void GoToNextOption();

        void GoToPrevOption();

    protected:
        
        void OnSizeChange(Vec2i oldSize);
        
        void OnPositionChange(Vec2i oldPosition);
        
    private:

        std::deque<std::string> options;

        Button prevButton;

        Button nextButton;

        Textbox textbox;

        int maxButtonWidth;

        Callable *callableObject;

        CallableFunction callback;

        int FindOption (std::string str);

        void PositionComponents ();
    };
}

#endif